/*
 * Graph.h
 *
 *  Created on: 31.03.2014
 *      Author: Medvedeva Anna
 */

#ifndef GRAPH_H_
#define GRAPH_H_

#include <utility>
#include <list>
#include <stack>
#include <deque>
#include <vector>
#include <fstream>
#include <stdlib.h>

using namespace std ;

//int count;

class Graph {
	int flagOrient;
	int numbVertices;
	int numbEdges;
	vector < vector <int> > connect_matrix;
	vector < list <int> > list_edges;

	void make_connect_matrix(ifstream &in);
	void make_connect_matrix();
	void make_list_edges(ifstream &in);
	void make_list_edges();
	int add_neighbors (int vertex, vector<int> &colors,stack <int > &dfsVertices);
	int add_neighbors (int vertex, vector<int> &colors,deque <int > &bfsVertices);
	void make_grey (vector <int> &colors, int vertex);
	void make_black (vector <int> &colors, int vertex);
	void dfs(int vertex);
	void dfs(int vertex, vector<int> &colorsVertices);
	int dfs(int vertex, vector <pair <int,int> > &infoVertices, pair<int,int> (*after_stack)(int, int)) ;
	int dfs(int vertex, int &time, vector<int> &colorsVertices, vector <pair <int,int> > &infoVertices, pair<int,int> (*after_stack)(int, int));
	void print_list_edges();
	void print_connect_matrix();

public:
	Graph();
	~Graph();
	void print_graph();
	void make_compact_digraph(ifstream &in);
	void make_compact_digraph();
	void dfs();
	void bfs(int vertex);
	friend void topological_sort(Graph graph);

};
/*
void* operator new[](size_t size);
void operator delete[](void *p);
void InitCount();
void PrintCount();
*/
void topological_sort(Graph graph);
pair <int,int> timeVert(int vertex, int time) ;

 /* namespace std */
#endif  //GRAPH_H_
